<?php

/**
 * This is the model class for table "translate".
 *
 * The followings are the available columns in table 'translate':
 * @property integer $id
 * @property integer $event_id
 * @property integer $language_id
 * @property string $main_title
 * @property string $sub_title
 * @property string $sub_title1
 * @property string $sub_title2
 * @property string $description
 * @property string $location
 * @property string $address
 *
 * The followings are the available model relations:
 * @property Events $event
 * @property Languages $language
 */
class Translate extends CActiveRecord
{
    public $cover;

    /**
     * Returns the static model of the specified AR class.
     * @param string $className active record class name.
     * @return Translate the static model class
     */
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return 'translate';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('event_id, language_id', 'numerical', 'integerOnly' => true),
            array('main_title, sub_title, sub_title1, sub_title2, location, address', 'length', 'max' => 255),
            //array('description', 'safe'),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('id, event_id, language_id, main_title, sub_title, sub_title1, sub_title2, description, location, address,gallery_id,text_contact, text_ticket', 'safe'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations()
    {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
            'event' => array(self::BELONGS_TO, 'Event', 'event_id', 'together' => true),
            'language' => array(self::BELONGS_TO, 'Language', 'language_id'),
            'gallery' => array(self::BELONGS_TO, 'Gallery', 'gallery_id'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'id' => 'ID',
            'event_id' => 'Event',
            'language_id' => 'Language',
            'main_title' => 'Main Title',
            'sub_title' => 'Sub Title',
            'sub_title1' => 'Sub Title1',
            'sub_title2' => 'Sub Title2',
            'description' => 'Description',
            'location' => 'Location',
            'address' => 'Address',
            'text_contact' => 'Text contact',
            'text_ticket' => 'Ticket text modify'
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search()
    {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('id', $this->id);
        $criteria->compare('event_id', $this->event_id);
        $criteria->compare('language_id', $this->language_id);
        $criteria->compare('main_title', $this->main_title, true);
        $criteria->compare('sub_title', $this->sub_title, true);
        $criteria->compare('sub_title1', $this->sub_title1, true);
        $criteria->compare('sub_title2', $this->sub_title2, true);
        $criteria->compare('description', $this->description, true);
        $criteria->compare('location', $this->location, true);
        $criteria->compare('address', $this->address, true);

        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
        ));
    }
}